Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Prevent repeated API calls in searchMessages after typing stops #655

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

SinghaAnirban005
Copy link
Contributor

Brief Title

Memoized debouncedSearch with useCallback to prevent re-creation on each render

Acceptance Criteria fulfillment

  • Ensure searchMessages is only called once after typing stops by debouncing the API call effectively.
  • Refactor useEffect dependencies to prevent redundant re-renders in the SearchMessages component.

Fixes #650

Video/Screenshots

EmbeddedChat._.Simple.-.Simple.Storybook.-.Brave.2024-10-31.15-56-44.mp4

Continuous API calls have been fixed

PR Test Details

Note: The PR will be ready for live testing at https://rocketchat.github.io/EmbeddedChat/pulls/pr-<pr_number> after approval.

@SinghaAnirban005
Copy link
Contributor Author

I have run Prettier and lint on the commit and made necessary changes @Spiral-Memory

@Spiral-Memory
Copy link
Collaborator

@devanshkansagra
You may test this.

@Spiral-Memory
Copy link
Collaborator

Spiral-Memory commented Nov 4, 2024

Can you please also fix this in this same PR ?, it has nothing to with your code, but this is happening in prod env : https://rocketchat.github.io/EmbeddedChat/?path=/story/embeddedchat-simple--simple

image

@SinghaAnirban005
Copy link
Contributor Author

Will look into it @Spiral-Memory

@SinghaAnirban005
Copy link
Contributor Author

Screenshot 2024-11-05 002501

@Spiral-Memory
It is the continuous requests that is overwhelming for the sever due to which it returns undefined in response
ultimately setting setMessageList as undefined

image

I shall improvise this PR soon

@Spiral-Memory
Copy link
Collaborator

Sure ❤️

@Spiral-Memory
Copy link
Collaborator

Hey @SinghaAnirban005
Is this ready for review ?

@SinghaAnirban005
Copy link
Contributor Author

Yes !! @Spiral-Memory

Copy link
Collaborator

@Spiral-Memory Spiral-Memory left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving to test. Review pending

@Spiral-Memory
Copy link
Collaborator

Ready to review ? @SinghaAnirban005

@SinghaAnirban005
Copy link
Contributor Author

Yes @Spiral-Memory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: searchMessages function called repeatedly after typing stops in Search Messages component
2 participants